<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ include file="../common/taglibs.jsp"%>
<%@ page import="java.util.*"%>
<%@ page import="com.opensymphony.xwork2.ActionSupport"%>
<%@ page import="net.aiform.account.pojo.*"%>
<%@ page import="net.aiform.bean.Constant"%>
<%@ page import="net.aiform.template.pojo.*"%>
<%@ page import="ext.cjt.*"%>
<%@ page import="net.aiform.template.action.*"%>
<script src="${ctx}/static/js/jquery.js" type="text/javascript"></script>
<script src="${ctx}/static/js/jquery.url.js" type="text/javascript"></script>
<script src="${ctx}/static/js/s.js" type="text/javascript"></script>
<body onload="listTemplate()">
</body>
<div id="template_list"></div>
<div id="testresult"></div>
<script type="text/javascript">
	function listTemplate() {
		var code = jQuery.url.attr("file");
		$.ajax( {
			url : "${ctx}/t/list/all",
			type : "post",
			dataType : "json",
			timeout : 5000,
			error : function() {
				alert("Error loading XML document");
			},
			success : function(root) {
				var json = root.json;
				listTemplateCallback(json);
			}
		});
	}
	function initTemplateList(json) {
		var list = json.data;
		for (i = 0; i < list.length; i++) {
			$("#template_list").append(
					"<br><a href='${ctx}/r/new/" + list[i].code + "'>"
							+ list[i].name + "</a>");
		}
	}
	function listTemplateCallback(message) {
		initTemplateList(message);
		if (typeof Object.toJSONString == "undefined") {
			$.getScript('${ctx}/static/js/json.js', function(js) {
				eval(js);
				$("#testresult").append("<br>"+message.toJSONString());
			});
		}
		//alert(json);
	}
</script>